[4주차] 강지훈/[feat] 액션 중심 API 구현#152
Merged
theSnackOverflow merged 3 commits intoLeets-Official:강지훈/mainfrom May 3, 2026
Hidden character warning
The head ref may contain hidden characters: "\uac15\uc9c0\ud6c8/4\uc8fc\ucc28"
Merged
Conversation
- ReportStatus enum 추가 (PENDING/RESOLVED)
- Report 엔티티에 status, resolvedBy, resolvedAt 필드 및 resolve() 도메인 메서드 추가
- DB 유니크 제약으로 중복 신고 방지 (reporter+post, reporter+comment)
- 자기 자신 신고 차단 로직 추가
- POST /api/v1/posts/{postId}/reports — 게시물 신고
- POST /api/v1/comments/{commentId}/reports — 댓글 신고
- POST /api/v1/reports/{reportId}/resolve — 신고 처리 완료 (PENDING→RESOLVED)
- 기존 targetType 기반 단일 엔드포인트 제거
- PostStatus enum 추가 (PUBLISHED/HIDDEN)
- Post 엔티티의 status 필드를 문자열에서 PostStatus enum으로 교체
- hide() 도메인 메서드 추가 (이미 HIDDEN이면 409 반환)
- POST /api/v1/posts/{postId}/hide — 게시물 숨김 (작성자 전용)
- 게시물 신고 엔드포인트 PostController로 통합
- Comment 엔티티에 accepted 필드 및 accept()/unaccept() 도메인 메서드 추가
- POST /api/v1/posts/{postId}/comments/{commentId}/accept — 댓글 채택
- 게시물 작성자만 채택 가능
- 게시물당 채택은 1개 (기존 채택 댓글은 자동 해제 후 신규 채택)
- 이미 채택된 동일 댓글 재요청 시 멱등 200 반환
- 댓글 신고 엔드포인트 CommentController로 통합
- 부모 댓글 검증 오류 코드 INVALID_REPORT_TARGET → INVALID_PARENT_COMMENT 교체
|
도메인 상태 변화(PENDING/RESOLVED, PUBLISHED/HIDDEN)를 명확하게 구분하고, PATCH /api/reports/{reportId}/resolve로 신고를 처리하는 로직도 체계적인것 같습니다! HTTP 상태코드(201, 400, 409 등)를 적절하게 사용하고, 다양한 예외 상황(중복 신고, 잘못된 요청)을 처리한 것이 인상적입니다. 배워갑니다 |
|
기능에 맞춰 에러 코드와 도메인 상태를 체계적으로 도식화하셔서, 신규 기능을 이해하는 데 필요한 시간이 적었습니다. 신고 기능에서 reporter_id를 도입하여 직관성을 높이고, 읽는 사람이 무엇을 신고하는지 확인하는 로직임을 좀 더 알기 쉬워 보입니다. 또 신고자와 피신고자를 구분해야 하는 상황에서 이런 명명 방식이 더 효과적일 것 같습니다. 오늘도 많이 배워갑니다. |
|
코드 잘 봤습니다! 이번 주차 핵심인 액션 중심 엔드포인트 설계를 정말 깔끔하게 잘해주셨네용 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. 과제 요구사항 중 구현한 내용
스스로 정의한 요구사항
구현한 액션 API
POST /api/v1/posts/{postId}/reports— 게시물 신고 (PENDING 생성, 중복·자기 신고 차단)POST /api/v1/comments/{commentId}/reports— 댓글 신고 (PENDING 생성, 중복·자기 신고 차단)POST /api/v1/reports/{reportId}/resolve— 신고 처리 완료 (PENDING → RESOLVED)POST /api/v1/posts/{postId}/hide— 게시물 숨김 (PUBLISHED → HIDDEN, 작성자 전용)POST /api/v1/posts/{postId}/comments/{commentId}/accept— 댓글 채택 (1게시물 1채택, 기존 채택 자동 해제)2. 핵심 변경 사항
도메인 상태 타입 도입
ReportStatusenum 추가 (PENDING/RESOLVED)PostStatusenum 추가 (PUBLISHED/HIDDEN)Post.status필드:String→PostStatusenum으로 교체Report엔티티에status,resolvedBy,resolvedAt필드 및resolve(User)도메인 메서드 추가Comment엔티티에accepted필드 및accept()/unaccept()도메인 메서드 추가중복 방지 로직
Report테이블에 DB 유니크 제약 추가:(reporter_id, post_id),(reporter_id, comment_id)ReportRepository에existsByReporter_IdAndPost_Id,existsByReporter_IdAndComment_Id추가CommentRepository에findByPost_IdAndAcceptedTrue추가신규 ErrorCode
R002R003R004P002C002기존 코드 개선
POST /api/v1/reports(targetType 분기) → 자원별 하위 경로로 분리INVALID_REPORT_TARGET→INVALID_PARENT_COMMENT교체3. 실행 및 검증 결과
실행:
./gradlew bootRun후 정상 기동 확인 (port 8080)게시물 신고
POST /api/v1/posts/1/reports중복 신고 차단
신고 처리 완료
POST /api/v1/reports/1/resolve이미 처리된 신고 재처리 차단
게시물 숨김
POST /api/v1/posts/1/hide댓글 채택
POST /api/v1/posts/1/comments/1/accept4. 완료 사항
resolve,hide,accept,unaccept)로 상태 변환 캡슐화./gradlew build성공 및 모든 시나리오 수동 검증 완료5. 추가 사항
http://localhost:8080/swagger-ui.htmlhttp://localhost:8080/h2-console(JDBC URL:jdbc:h2:mem:blog)제출 체크리스트
강지훈/main브랜치다강지훈/4주차브랜치다Reviewer 참고